{% extends "_layout.html" %}
{% import "component/statistics.njk" as statistics %}
{# 样式代码 #}
{% block style %}
<style type="text/css">
	body {
		background-color: #fff;
	}
	
	.mui-content {
		padding: 35px;
		background-color: #fff;
	}
</style>
<title>登录</title>
{% endblock %} {# bodyd代码#} {% block body %}
<div class="mui-content">
	<div class="login-top">
		<!--logo-->
		<img class="login-logo" src="images/logo.png" />
		<p class="login-wellcome">毛笔教育</p>
		<!--用户名、密码输入框-->
		<div class="login-input">
			<form>
				<div class="login-inputs xw-border-bottom">
					<input class="login-in" type="text" name="loginName" id="username" placeholder="请输入用户名" />
				</div>
				<div class="login-inputs xw-border-bottom">
					<input class="login-in" type="password" name="password" id="password" placeholder="请输入密码" />
					<a class="login-forget" href="findpwd">忘记密码</a>
				</div>
				<input class="login-submit" type="submit" value="登录" />
			</form>

			<!--<div class="login-submit">登录</div>-->

		</div>
	</div>
</div>

{% endblock %} {#js代码#} {% block js %}
<script>
	mui.init();

    $(function(){
        pushHistory();
        window.addEventListener("popstate", function(e) {
                 WeixinJSBridge.call('closeWindow');
        }, false);
        function pushHistory() {
            var state = {
                title: "title",
                url: "#"
            };
            window.history.pushState(state, "title", "#");
        }
    });

	$('.login-submit').on('click',function(){
	   event.preventDefault();
	   // $('.login-submit').attr('disabled','disabled');
		var user = $('form').serialize();
        mui.ajax('/login',{
            data:user,
            dataType:'json',//服务器返回json格式数据
            type:'post',//HTTP请求类型
            timeout:10000,//超时时间设置为10秒；
            success:function(data){
                if(data.code!=200){
                    mui.toast(data.message);
				}else{
                    mui.toast('登录成功');
                    window.location.replace('/index');
				}
            },
            error:function(xhr,type,errorThrown){
                console.log('异常');
            }
        });
	});

    (function($){
        $.fn.serializeJson=function(){
            var serializeObj={};
            $(this.serializeArray()).each(function(){
                serializeObj[this.name]=this.value;
            });
            return serializeObj;
        };
    })(jQuery);


</script>

<!--flotdemo-->
{% endblock %}